package com.heima.dome1;

import com.heima.domain.Teacher;

import java.util.Comparator;
import java.util.TreeSet;

public class TestTeacher {
    public static void main(String[] args) {
        TreeSet<Teacher> tc=new TreeSet<>(new Comparator<Teacher>() {
            @Override
            public int compare(Teacher o1, Teacher o2) {
                int a=o1.getAge()-o2.getAge();

                return a==0?o1.getName().length()-o2.getName().length():a;
            }
        });

        Teacher t1=new Teacher("zhangsan",19);
        Teacher t2=new Teacher("lisi",19);
        Teacher t3=new Teacher("wangwu",19);
        Teacher t4=new Teacher("zhaoliu",19);

        tc.add(t1);
        tc.add(t2);
        tc.add(t3);
        tc.add(t4);

        System.out.println(tc);
    }
}
